package com.ruoyi.module.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.module.domain.BookExtInfo;
import com.ruoyi.module.domain.BookExtInfoExample;
import com.ruoyi.module.mapper.BookExtInfoMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 图书扩展信息Service业务层处理
 *
 * @author ruoyi
 * @date 2022-04-13
 */
@DS("bookmgr")
@Service
@RequiredArgsConstructor
public class CmBookInfoExtService {
    private final BookExtInfoMapper bookExtInfoMapper;

    /**
     * 查询图书扩展信息
     *
     * @param id 图书扩展信息主键
     * @return 图书扩展信息
     */
    public BookExtInfo selectCmBookInfoExtById(Long id) {
        return bookExtInfoMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询图书扩展信息列表
     *
     * @param cmBookInfoExt 图书扩展信息
     * @return 图书扩展信息
     */
    public List<BookExtInfo> selectCmBookInfoExtList() {
        BookExtInfoExample example = new BookExtInfoExample();

        return bookExtInfoMapper.selectByExample(example);
    }

    /**
     * 新增图书扩展信息
     *
     * @param cmBookInfoExt 图书扩展信息
     * @return 结果
     */
    public int insertCmBookInfoExt(BookExtInfo cmBookInfoExt) {
        return bookExtInfoMapper.insert(cmBookInfoExt);
    }

    /**
     * 修改图书扩展信息
     *
     * @param cmBookInfoExt 图书扩展信息
     * @return 结果
     */
    public int updateCmBookInfoExt(BookExtInfo cmBookInfoExt) {
        return bookExtInfoMapper.updateByPrimaryKey(cmBookInfoExt);
    }

    /**
     * 批量删除图书扩展信息
     *
     * @param ids 需要删除的图书扩展信息主键
     * @return 结果
     */
    public int deleteCmBookInfoExtByIds(List<Long> ids) {
        BookExtInfoExample example = new BookExtInfoExample();
        example.or().andIdIn(ids);

        return bookExtInfoMapper.deleteByExample(example);
    }

    /**
     * 删除图书扩展信息信息
     *
     * @param id 图书扩展信息主键
     * @return 结果
     */
    public int deleteCmBookInfoExtById(Long id) {
        return bookExtInfoMapper.deleteByPrimaryKey(id);
    }
}
